1. Technical Field
This application relates generally to techniques for use in a computer system in connection with data structures.
2. Description of Related Art
A data structure may be characterized as a representation of data having a particular organization. The data structure may be a collection of data hems stored in a particular way where the data items may be of varying types. An example of a data structure is a linked list of list elements. Each list element may include one or more data items. Each list element is connected or mapped to another list element using pointers or addresses, array indices, and the like, depending on the way in which the linked list is implemented. Another example of a data structure is a record made of an aggregated collection of data items or fields.
Computer programs may be written in a variety of different programming languages which provide different ways of defining a data structure. A programming language may specify a syntax used to express the layout or definition of the data structure. For example, a programming language may be used to define a record layout by specifying the particular data items included in a record instance. When creating an instance of the data structure, storage for the structure may be allocated to include all data items specified in the layout as coded. When an instance of the data structure is referenced, all data items of the instance may be loaded into memory.
When specifying the data items included in the data structure, there may be a set of common or general items used for each instance of the data structure. Each instance of the data structure may also include additional information that may vary with each instance. For example, a data structure may be defined for an insurance claim. There may be a set of common data items relevant to all types of possible insurance claims such as, for example, based on a home, automobile, and the like. Additionally, there may be data items which vary with the type of insurance claim. Depending on the particular implementation, different techniques may be used to define the data structure. The data structure may be defined to include all possible data items that may be needed for all possible claim types. For example, if 3 data items are needed for an automobile claim and 5 data items (different from the previous 3 data items) are needed for a homeowner's claim, the data structure definition may include data items for each of the foregoing 8 data items as well as any common items. The foregoing has drawbacks including the additional memory allocated for each instance of the data structure even though not all data items are used.
A programming language may include a language construct to store different data items in shared memory. For example, using the C programming language, a structure may be defined to include a union of data items where only one item in the union can be used at any time. A union of possible alternative data items may be defined. All data items of the union are associated with a same shared memory location which may have a size associated with the largest of the data items.
As yet another alternative, an inheritance model may be defined using classes. A first class may be defined as a superclass or parent class for the common data items. Subclasses or child classes of the parent class may also be defined. With respect to the exemplary insurance claims, a parent class may be defined to include the data items common to all types of insurance claims. For the superclass or parent class, subclasses or child classes may be defined to include the additional data items of information that may vary with each type of claim. For example, subclasses for home and auto may be defined within the superclass insurance claim. Such inheritance models may require a complex class hierarchy and class definitions to account for the possible variations in structures. Furthermore, when instantiating an instance of an object of one of the subclasses, storage may be allocated for the common data items (of the superclass) and also the additional data items of the subclass. When an instance of an object of the subclass is created, storage may be allocated for all common data items of the parent class and the additional data items for that subclass.